// stores/counter.js
import { defineStore } from 'pinia';
import { ref , computed } from 'vue'

export const useUserStore = defineStore('user', () => {
	const user = ref({
		userId:1,
		userPhone: '',
		userName:'',
		userAvatar:''
	})
	
	  // 定义清空用户信息的方法
	  function resetUser() {
	    user.value = {
	      userId: '',
	      userPhone: '',
	      userName: '',
	      userAvatar: ''
	    };
	  }
	  
	  // 便捷地获取 userId 的 getter 方法
	  const userId = computed(() => user.value.userId);
	  
	return { user,resetUser,userId }
}, {
	persist: {
		storage: {
			getItem: uni.getStorageSync,
			setItem: uni.setStorageSync
		}
	}
});


